home *** CD-ROM | disk | FTP | other *** search
- class classes.fx.Asteroid
- {
- var size;
- var id;
- var x;
- var y;
- var dir;
- var colorV;
- var power;
- var clip;
- var feeler;
- var xMov;
- var yMov;
- var c = 0;
- var sizeArray = [[1,3],[4,9],[10,17],[18,23],[24,27]];
- var yank = false;
- var feelerCount = 0;
- var feelerBreak = false;
- var fast = false;
- function Asteroid(px, py, psize, pdir, pcolorV, pid, pfast)
- {
- this.size = psize;
- this.id = pid;
- this.x = px;
- this.y = py;
- this.dir = pdir;
- this.colorV = pcolorV;
- this.power = this.size * 6;
- this.fast = pfast;
- _root.d = _root.d + 1;
- this.clip = _root.attachMovie("asteroid","asteroid" + this.id + "Clip",_root.d + 75000);
- this.clip.gotoAndStop(this.colorV);
- this.clip.body.gotoAndStop(_root.randRange(this.sizeArray[this.size - 1][0],this.sizeArray[this.size - 1][1]));
- if(!_root.astField)
- {
- _root.d = _root.d + 1;
- this.feeler = this.clip.attachMovie("asteroidFeeler","asteroidFeeler" + this.id,_root.d + 75000);
- this.feeler._x = -100;
- this.feeler._y = -100;
- this.feeler._width = 50 + this.clip.body._width;
- this.feeler._height = 50 + this.clip.body._height;
- }
- if(this.dir == "U")
- {
- this.xMov = _root.randRange2(this.size - 9,-1 * (this.size - 9));
- this.yMov = _root.randRange2(this.size - 9,0);
- }
- else if(this.dir == "D")
- {
- this.xMov = _root.randRange2(this.size - 9,-1 * (this.size - 9));
- this.yMov = _root.randRange2(0,-1 * (this.size - 9));
- }
- else if(this.dir == "L")
- {
- this.xMov = _root.randRange2(this.size - 9,0);
- this.yMov = _root.randRange2(this.size - 9,-1 * (this.size - 9));
- }
- else
- {
- this.xMov = _root.randRange2(0,-1 * (this.size - 9));
- this.yMov = _root.randRange2(this.size - 9,-1 * (this.size - 9));
- }
- if(this.fast)
- {
- this.xMov *= 0.4;
- this.yMov *= 2.5;
- }
- this.xMov *= _root.dif.speed;
- this.yMov *= _root.dif.speed;
- this.clip._x = this.x;
- this.clip._y = this.y;
- this.clip._rotation = random(4) * 90;
- }
- function bombed()
- {
- _root.createExploA([this.x,this.y,this.size * 20 + 40,_root.randRange(75,100)]);
- this.yank = true;
- }
- function main()
- {
- this.c = this.c + 1;
- if(this.clip.body.hitTest(_root[_root.char + "Clip"]))
- {
- _root[_root.char].hit(this.xMov,this.yMov,100,this.power);
- _root.createExploA([this.x,this.y,this.size * 20 + 40,_root.randRange(75,100)]);
- var _loc7_ = !(this.size == 2 || this.size == 4) ? this.size : this.size - 1;
- _root.audio.playLevel4("astX" + _loc7_ + "_" + (random(2) + 1),_root.randRange(25,45));
- if(this.size > 2)
- {
- if(this.size == 5)
- {
- if(random(2) > 0)
- {
- _root.createPowerUp([this.x,this.y,"gem" + _root.randRange(1,6)]);
- }
- }
- this.size -= 1;
- var _loc4_ = _root.randRange(1,2);
- var _loc3_ = 0;
- while(_loc3_ < _loc4_)
- {
- _root.createAsteroid([this.x,this.y,this.size,tempDir,this.colorV]);
- _loc3_ = _loc3_ + 1;
- }
- }
- this.yank = true;
- }
- _loc3_ = 0;
- var _loc8_ = _root.broShots.length;
- while(_loc3_ < _loc8_)
- {
- var _loc5_ = _root.broShots[_loc3_] + "Clip";
- if(this.clip.body.hitTest(_root[_loc5_]))
- {
- _root.createExploA([this.x,this.y,this.size * 20 + 40,_root.randRange(75,100)]);
- _loc7_ = !(this.size == 2 || this.size == 4) ? this.size : this.size - 1;
- _root.audio.playLevel4("astX" + _loc7_ + "_" + (random(2) + 1),_root.randRange(25,45));
- _root[_root.char].fc = _root[_root.char].fireFreq - _root.rapidVar - 1;
- var _loc6_ = _root.broShots[_loc3_];
- _root[_loc6_].exploX = this.x + this.clip.body._width / 2;
- _root[_loc6_].exploY = this.y + this.clip.body._height / 2;
- var tempDir = _root[_loc6_].dir;
- _root[_loc6_].hit();
- if(this.size > 2)
- {
- if(this.size == 5)
- {
- if(random(2) > 0)
- {
- _root.createPowerUp([this.x,this.y,"gem" + _root.randRange(1,6)]);
- }
- }
- this.size -= 1;
- _loc4_ = _root.randRange(1,2);
- _loc3_ = 0;
- while(_loc3_ < _loc4_)
- {
- _root.createAsteroid([this.x,this.y,this.size,tempDir,this.colorV]);
- _loc3_ = _loc3_ + 1;
- }
- }
- this.yank = true;
- break;
- }
- _loc3_ = _loc3_ + 1;
- }
- if(!_root.astField)
- {
- _loc3_ = 0;
- _loc8_ = _root.enemyShots.length;
- while(_loc3_ < _loc8_)
- {
- _loc5_ = _root.enemyShots[_loc3_] + "Clip";
- if(this.clip.body.hitTest(_root[_loc5_]))
- {
- _root.createExploA([this.x,this.y,this.size * 20 + 40,_root.randRange(75,100)]);
- _loc7_ = !(this.size == 2 || this.size == 4) ? this.size : this.size - 1;
- _root.audio.playLevel4("astX" + _loc7_ + "_" + (random(2) + 1),_root.randRange(25,45));
- _loc6_ = _root.enemyShots[_loc3_];
- var tempDir = _root[_loc6_].dir;
- _root[_loc6_].hit(this.size);
- if(this.size > 2)
- {
- if(this.size == 5)
- {
- if(random(2) > 0)
- {
- _root.createPowerUp([this.x,this.y,"gem" + _root.randRange(1,6)]);
- }
- }
- this.size -= 1;
- _root.createAsteroid([this.x,this.y,this.size,tempDir,this.colorV]);
- }
- this.yank = true;
- break;
- }
- _loc3_ = _loc3_ + 1;
- }
- if(random(3) == 0)
- {
- _loc3_ = 0;
- _loc8_ = _root.chars.length;
- while(_loc3_ < _loc8_)
- {
- _loc5_ = _root.chars[_loc3_] + "Clip";
- if(!this.feelerBreak)
- {
- if(this.feeler.hitTest(_root[_loc5_]))
- {
- _loc6_ = _root.chars[_loc3_];
- _root[_loc6_].evade();
- this.feelerCount = 0;
- this.feelerBreak = true;
- }
- }
- if(this.clip.body.hitTest(_root[_loc5_]))
- {
- _root.createExploA([this.x,this.y,this.size * 20 + 40,_root.randRange(75,100)]);
- _loc7_ = !(this.size == 2 || this.size == 4) ? this.size : this.size - 1;
- _root.audio.playLevel4("astX" + _loc7_ + "_" + (random(2) + 1),_root.randRange(25,45));
- _loc6_ = _root.chars[_loc3_];
- var tempDir = _root[_loc6_].dir;
- _root[_loc6_].bombed(this.power);
- if(this.size > 2)
- {
- if(this.size == 5)
- {
- if(random(2) > 0)
- {
- _root.createPowerUp([this.x,this.y,"gem" + _root.randRange(1,6)]);
- }
- }
- this.size -= 1;
- _root.createAsteroid([this.x,this.y,this.size,tempDir,this.colorV]);
- }
- this.yank = true;
- break;
- }
- _loc3_ = _loc3_ + 1;
- }
- if(this.feelerBreak)
- {
- this.feelerCount = this.feelerCount + 1;
- if(this.feelerCount == 5)
- {
- this.feelerBreak = false;
- }
- }
- }
- }
- if(this.c > 100)
- {
- if(this.x > 1050 || this.x < -50 || this.y < -50 || this.y > 650)
- {
- this.yank = true;
- }
- }
- if(this.yank)
- {
- _root.removeFX("asteroid" + this.id);
- }
- this.x += this.xMov;
- this.y += this.yMov;
- this.clip._x = this.x;
- this.clip._y = this.y;
- }
- }
-